package cn.wsalix.templet.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.SimpleEntity;
import cn.wsalix.templet.type.PlaceDataEnum;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * @author jskyme 模板位置
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "TEMPLET_PAGE_PLACE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(callSuper = false)
public class TempletPagePlace extends SimpleEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2975901289585264896L;
	/**
	 * 
	 */
	private String placeCode;
	// 位置对应数据
	// 菜单
	// 文章列表
	// 文章分类
	// 广告
	private PlaceDataEnum dataType;
	@JsonIgnore
	@ManyToOne(cascade = CascadeType.MERGE, optional = false, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_TPP_TP"), name = "TEMPLET_PAGE_ID")
	private TempletPage templetPage;
	/*
	 * @JsonIgnore
	 * 
	 * @ManyToOne(cascade = CascadeType.MERGE, optional = false, fetch =
	 * FetchType.LAZY)
	 * 
	 * @JoinColumn(name = "TEMPLET_PLACE_ID") private TempletPlace templetPlace;
	 */
	/*
	 * @ManyToOne(cascade=CascadeType.MERGE,optional=false,fetch=FetchType.LAZY
	 * )
	 * 
	 * @JoinColumn(name = "TEMPLET_PAGE_ID") private TempletPage templetPage;
	 */
	/*
	 * @JsonIgnore
	 * 
	 * @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy =
	 * "templetPagePlace") private List<TempletPagePlace> templetPagePlace;
	 */
}
